<style scoped>
.pro-con {
    padding: 0 20px;
    margin-bottom: 50px;
}
.pro-con .ivu-form-item{
    margin-bottom: 0;
}
.hr{
    border:0;
    background-color:#DEDEDE;
    height:1px;
    margin: 15px 0;
}
.pro-con .ivu-col{
    padding-right: 0 !important;

}
 .fr{
    float: right;
}
.pro-pagesize .mr10{
    margin-right: 10px;
}
.search-h3{
    font-size: 18px;
    color: #ef8412;
    font-weight: normal;
    margin-bottom: 20px;
}


    /*//////////////////////////////*/

.pro-card {
    margin-bottom: 10px;
}
.pro-card-head {
    background-color: #e6e7eb;
    line-height: 38px;
    border: 1px solid #ddd;
}
.pro-card-title {
    font-size: 14px;
    color: #333;
    font-weight: bold;
    padding-left: 20px;
}
.pro-card-headr {
    padding-right: 10px;
    text-align: right;
}
.pro-card-content {
    clear: both;
}
.pro-paramname {
    text-align: center;
    background-color: #e6e7eb;
    font-size: 14px;
    color: #333;
    border-right: 1px solid #ddd;
}
.pro-paramvalue {
    padding-left: 30px;
    border-right: 1px solid #ddd;
}
.pro-card-contentrow {
    line-height: 40px;
    border-left: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
}
.mb10{
    margin-bottom: 10px;
}
.search-h3{
    font-size: 18px;
    color: #ef8412;
    font-weight: normal;
    margin-bottom: 20px;
}
.search-form{
    border-bottom: 1px solid #d9d9d9;
}
.search-form .ivu-col{
    margin-bottom: 15px;
}
.clear{
    clear: both;
}
.table-theme{
    clear: both;
}
.table-action{
    padding-top: 10px;
    padding-bottom: 15px;
}
.inline-cut{
    margin-left: 15px;
    margin-right: 15px;
    width: 1px;
    height: 25px;
    background-color: #edf2f6;
}
.pro-pagesize{
    margin-bottom:10px;

}
.footer{
    position: fixed;
    padding: 0 30px;
    bottom:0;
    background-color:#FFF;
    box-shadow: -1px -3px 2px #E3E3E3;
}
.pro{
}
.pro_head_img{
}
.pro_show_img{
    position: relative;
    height:120px;
}
.close{
    width:15px;
    height:15px;
    position: absolute;
    right:7px;top:7px;
    border-radius: 50%;
    background-color:red;
    color:#FFF;
    line-height:15px;
    text-align: center;
    cursor: pointer;
}
.imgAdd{
    border:1px dotted #EEEEEE;
    height:50px;
    margin-top:10px;
    line-height: 50px;
    text-align: center;
    background-color: #FBFCFE;
}
.site-wrapper {
    width: 95%;
    margin: 0 auto;
}
.bm-view {
    width: 100%;
    height: 300px;
    margin-bottom: 20px;
}
.cropper-wrapper {
    margin-top: 10px;
    height: 400px;
}
.cropper-box{
    height: 300px;
}
.btn {
    display: inline-block;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    text-align: center;
    box-sizing: border-box;
    outline: none;
    margin:20px 10px 0px 0px;
    padding: 9px 15px;
    font-size: 14px;
    border-radius: 4px;
    color: #fff;
    background-color: #50bfff;
    border-color: #50bfff;
    transition: all .2s ease;
    text-decoration: none;
    user-select: none;
}
.iconclass{
    display: inline-block;
    width: 58px;
    background: #fff;
    border: 1px dashed #dddee1;
    border-radius: 4px;
    text-align: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: border-color .2s ease;
    height:58px;
    line-height: 58px;
}
.cailiao{
    margin: 10px 0px 15px ;
}
    .cailiao span:first-child{
        display: inline-block;
        width: 20%;
        height: 36px;
        line-height: 36px;
        font-size: 14px;
        border: 1px solid #A9A9A9;
        border-right: 0;
        text-align: center;
        vertical-align: middle;
        background-color: #FAFAFA;
        font-weight: 500;
    }
.cailiao .inputBox{
    height: 36px;
    line-height: 34px;
    width: 80%;
    vertical-align: middle;
    padding-left: 5px;
    border:1px solid #A9A9A9;
    display: inline-block;
}
.cailiao .inputBox input{
    border: 0;
    width: 100%;
    outline: none;
}
#footer .ivu-btn-large{
    padding: 6px 10px 7px 10px;
}
</style>
<style>
    .duty .ivu-date-picker-rel:after, .duty .ivu-select:after {
        content: "";
        position: absolute;
        top: 1px;
        bottom: 1px;
        right: 1px;
        width: 35px;
        height: 34px;
        border-left: 1px solid #bebebe;
        background-color: #FAFAFA;
    }
    .duty .ivu-form .ivu-form-item-label{
        border:1px solid #BEBEBE;
        border-right: 0;
        background-color: #FAFAFA;
    }
    .duty .ivu-select-single .ivu-select-selection,.duty .ivu-input{
        height: 36px ;
        line-height: 36px;
        border-radius: 0 2px 2px 0;
        border-color: #BEBEBE;
    }
    .duty .ivu-select-single .ivu-select-selection .ivu-select-placeholder,.duty .ivu-select-single .ivu-select-selection .ivu-select-selected-value{
        height: 34px ;
        line-height: 34px;
        padding-right: 34px;
    }
    .duty .ivu-select-arrow{
        right:12px;
        z-index: 9;
    }
    .duty textarea.ivu-input{
        height: inherit;
    }
    .modal5 .ivu-modal-footer{
        background-color: #F2F2F2;
    }
</style>
<template>
    <div class="pro-list">
        <product-title></product-title>
        <div class="pro-con">
            <div class="pro-con-f common-box-body">
                <Row>
                    <h3 class="search-h3 huang">
                        快速搜索
                    </h3>
                        <Form  :model="searchForm" class="search-form">
                            <Col :xs="6" :sm="6" :md="6" :lg="6">
                                <Form-item>
                                    <Select size="large" v-model="searchForm.cid"  placeholder="供应商简称" filterable :transfer="true">
                                        <Option value="">全部</Option>
                                        <Option v-for="(item,index) in cname_list" :value="item.cid" :key="item.cid">{{item.shortn}}</Option>
                                    </Select>
                                </Form-item>
                            </Col>
                            <Col :xs="6" :sm="6" :md="6" :lg="6" style="padding-right:15px;">
                                <Form-item>
                                    <Input size="large" type="text" v-model="searchForm.name" placeholder="请输入产品名称" />
                                </Form-item>
                            </Col>
                            <Col :xs="6" :sm="6" :md="6" :lg="6" style="padding-right:15px;">
                                <Form-item>
                                    <Select size="large"  v-model="searchForm.is_main" placeholder="请选择产品主附险类型" :transfer="true">
                                        <Option value=" ">全部</Option>
                                        <Option value="1">主险</Option>
                                        <Option value="2">附加险</Option>
                                        <Option value="3">组合险</Option>
                                    </Select>
                                </Form-item>
                            </Col>
                            <Col :xs="2" :sm="2" :md="2" :lg="2"  offset='4'>
                                <Form-item  style="padding-right:0px;">
                                    <Button size="large"  class="fr" type="primary" icon="ios-search" @click="search">搜索</Button>
                                </Form-item>
                            </Col>
                            <div class="clear"></div>
                        </Form>
                </Row>
            </div>
            <div class="table-theme highlight_table">
                <Table :loading="tableloading" ref="currentRowTable" @on-current-change="tableCurrentChange($event)" size="large" stripe highlight-row border :columns="columns1" :data="prolist" class=""></Table>
            </div>
            <div id="footer">
                <Row class="pro-pagesize">
                    <Col :md="16" :lg="16" >
                            <Button v-if="$isShow('pro_ratio/create')" type="info" :disabled="tableaction" size="large" class="fl mr10"   @click="toDetail">编辑</Button>
                    </Col>
                    <Col :md="8" :lg="8" class="tRight">
                        <Page ref="pages" :current="currentpage" :total="listTotal" show-total show-sizer :page-size="pagesize" @on-change="pageChange" @on-page-size-change="pageSizeChange" placement="top" class="page"></Page>
                    </Col>
                </Row>
            </div>
        </div>
    </div>
</template>

<script>
import productTitle from '../../components/productTitle'
import { get_list } from '../../api/pro'
import { _get_parter_list } from '../../api/product_v2'
export default {
    data() {
        return {
            prolist:[],//列表数据
            cname_list:[],//供应商收集
            loading: true,
            tableaction:true,
            tableloading:false,
            currentpage:1,
            searchForm: {
                name:'',
                is_main:"",
                p:1,
                pagesize:10,
            }, //搜索的表格数据
            columns1: [
                {
                    title: '供应商简称',
                    key: 'cname',
                    align:'center',
                },
                {
                    title: '产品名称',
                    key: 'name',
                    align:'center',
                },
                {
                    title: '主附险类型',
                    key: 'is_main',
                    align:'center',
                    render: (h, params) => {                                               
                        return h('div', {
                          
                        },params.row.is_main==1?'主险':params.row.is_main==2?'附加险':params.row.is_main==3?'组合险':'')
                    }
                },
                {
                    title: '标准系数',
                    key: 'standard',
                    align:'center',
                    render:(h,params)=>{
                        return h('div',
                            (function(){
                                let str = '';
                                params.row.standard.map(item=>{
                                   str+=item.pay_period+"/"+item.val+"%  "
                                })
                                return str;
                            })()
                        )
                    }
                },
                {
                    title: '价值系数',
                    key: 'worth',
                    align:'center',
                    render:(h,params)=>{
                        return h('div',
                            (function(){
                                let str = '';
                                params.row.worth.map(item=>{
                                    str+=item.pay_period+"/"+item.val+"%  "
                                })
                                return str;
                            })()
                        )
                    }
                },
                {
                    title: '综合标保系数',
                    key: 'year_standard',
                    align:'center',
                    render:(h,params)=>{
                        return h('div',
                            (function(){
                                let str = '';
                                params.row.year_standard.map(item=>{
                                    str+=item.pay_period+"/"+item.val+"%  "
                                })
                                return str;
                            })()
                        )
                    }
                },
            ],
            listTotal: 0, //产品总数
            p:1,
            pagesize:10,
        };
    },
    components: {
        productTitle,
    },
    computed:{
        
    },
    created() {
        this.getList();
        this.all_company();
        // this.ok()
        // this.all_company();
        // this.get_cate_one();
    },
    mounted () {
    },
    activated(){
    },
    methods: {
        // 供应商列表服务
        all_company(){
            new Promise((resolve,reject)=>{
                _get_parter_list().then(res=>{
                    if(res.data.err==0){
                        this.cname_list = res.data.data;
                        //this.searchForm.cpid = this.$route.query.cpid
                    }else{
                        this.$Message.error(res.data.info);
                    }
                    resolve();
                }).catch(error=>{
                    reject(error);
                })
            })
        },
        // ok(){
        //     var href  =  window.location.href;//完整的url
        //     var protocol  =  window.location.protocol;//协议
        //     var hostname  =  window.location.hostname;//主机名
        //     var host  =  window.location.host;//主机名+端口号
        //     var port = window.location.port;//端口号
        //     var pathname = window.location.pathname;//当前URL的路径部分
        //     var search = window.location.search;//路径的查询部分
        //     var hash = window.location.hash;//开始的锚点
        //     console.log(href,"href");
        //     console.log(protocol,"protocol");
        //     console.log(hostname,"hostname");
        //     console.log(host,"host");
        //     console.log(port,"port");
        //     console.log(pathname,"pathname");
        //     console.log(search,"search");
        //     console.log(hash,"hash");
        // },
        //选中当前行数据
        tableCurrentChange(currentRow,oldCurrentRow){

            this.tableaction = false;
            this.current = currentRow;
            console.log(this.current,"this.current..........")
        },
        //编辑
        toDetail(){
            this.$router.push({name:'pro_scaling',params:{id:this.current.ptid,name:this.current.name,if:2}});
        },
        search(){
            this.searchForm.p = 1
            this.p = 1
            this.searchForm.pagesize=this.pagesize;
            this.tableaction = true
            this.getList(-1)
        },
        getList(id) {
            this.searchForm.p=this.p;
            this.searchForm.pagesize=this.pagesize;
            new Promise((resolve, reject) => {
                get_list(this.searchForm).then(response => {
                    console.log(response.data,"........")
                    if(response.data.err==0){
                        this.listTotal = response.data.data.total;
                        this.prolist = response.data.data.data;
                        this.tableloading = false
                        if(id == -1){
                            this.$refs['pages'].currentPage = 1
                        }
                    }else{
                        this.$Message.error(response.data.info);
                    }
                    resolve();
                }).catch(error => {
                    reject(error);
                });
            });
        },
        pageChange(value) {
            this.p = value;
            this.getList();
        },
        pageSizeChange(value) {
            this.pagesize = value;
            this.getList();
        },
    }

};
</script>
